/************************************************************************
  Scheme interpreter
  
  Copyright (C) 2010 Marioly Garza 

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU Lesser General Public License as
  published by the Free Software Foundation, either version 3 of the
  License, or (at your option) any later version.
  
  This program is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  Lesser General Public License for more details.
  
  You should have received a copy of the GNU Lesser General Public
  License along with this program. If not, see
  <http://www.gnu.org/licenses/>.

************************************************************************/

#include "symbols.h"

symbols* symbols::instance(NULL);

symbols* symbols::get_instance()
{
    if (instance == NULL)
        instance = new symbols();
    return instance;
}

void symbols::install_primitives()
{
    table["#t"] = (object*)new sboolean(true);
    table["#f"] = (object*)new sboolean(false);

    table["apply"] = (object*)new native("apply", &native::apply, 2);
    table["car"] = (object*)new native("car", &native::car, 1);
    table["cdr"] = (object*)new native("cdr", &native::cdr, 1);
    table["cons"] = (object*)new native("cons", &native::cons, 2);
    table["define"] = (object*)new native("define", &native::define, 2);
    table["display"] = (object*)new native("display", &native::display, 1);
    table["equal?"] = (object*)new native("equal?", &native::equal, 2);
    table["if"] = (object*)new native("if", &native::_if, 3);
    table["lambda"] = (object*)new native("lambda", &native::lambda, 2);
    table["length"] = (object*)new native("length", &native::length, 1);
    table["list"] = (object*)new native("list", &native::list, -1);
    table["list?"] = (object*)new native("list?", &native::islist, 1);
    table["load"] = (object*)new native("load", &native::load, 1);

    table["null?"] = (object*)new native("null?", &native::isnull, 1);
    table["quote"] = (object*)new native("quote", &native::quote, -1);

    table["+"] = (object*)new native("+", NULL, -1);
    table["-"] = (object*)new native("-", NULL, -1);
    table["*"] = (object*)new native("*", NULL, -1);
    table["/"] = (object*)new native("/", NULL, -1);

    table[">"] = (object*)new native(">", NULL, 2);
    table["<"] = (object*)new native("<", NULL, 2);
    table[">="] = (object*)new native(">=", NULL, 2);
    table["<="] = (object*)new native("<=", NULL, 2);
    table["="] = (object*)new native("=", NULL, 2);
}
